package devices

import (
	"api/internal/respons"
	"context"
	"device_srv/deviceclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

// @Summary 设备信息删除
// @Description 拥有对应权限的用户可进行删除
// @Tags 认证
// @Accept json
// @Produce json
// @Param data body types.SendSmsReques true ""
// @Success 200 {object} types.Response
// @Failure 400 {string} types.Response
// @Failure 500 {string} types.Response
// @Router /devices/devicesDelete [post]
type DevicesDeleteLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDevicesDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DevicesDeleteLogic {
	return &DevicesDeleteLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// DevicesDelete 设备信息删除
func (l *DevicesDeleteLogic) DevicesDelete(req *types.DevicesDeleteRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	devicesDelete, err := l.svcCtx.DeviceRpc.DevicesDelete(l.ctx, &deviceclient.DevicesDeleteRequest{
		Id: req.Id,
	})

	if err != nil {
		return respons.Error(400, "删除失败", err.Error()), err
	}
	return respons.Success(devicesDelete), nil
}
